1
|
|
|
/** |
2
|
|
|
* Test for class Card. |
3
|
|
|
*/ |
4
|
|
|
"use strict"; |
5
|
|
|
|
6
|
|
|
/* global describe it */ |
7
|
|
|
|
8
|
|
|
var assert = require("assert"); |
9
|
|
|
const Card = require("../../src/card/card"); |
10
|
|
|
|
11
|
|
|
describe("Get cards with different values", function() { |
12
|
|
|
describe("Get card with value 0", function() { |
13
|
|
|
it("should be card ♣A", function() { |
14
|
|
|
let card = new Card(); |
15
|
|
|
let res = card.getCard(0); |
16
|
|
|
|
17
|
|
|
assert.equal(res, "♣A"); |
18
|
|
|
}); |
19
|
|
|
|
20
|
|
|
it("should have rank 14", function() { |
21
|
|
|
let card = new Card(); |
22
|
|
|
let res = card.getRank(0); |
23
|
|
|
|
24
|
|
|
assert.equal(res, 14); |
25
|
|
|
}); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
describe("Get card with value 1", function() { |
29
|
|
|
it("should be card ♣2", function() { |
30
|
|
|
let card = new Card(); |
31
|
|
|
let res = card.getCard(1); |
32
|
|
|
|
33
|
|
|
assert.equal(res, "♣2"); |
34
|
|
|
}); |
35
|
|
|
|
36
|
|
|
it("should have rank 2", function() { |
37
|
|
|
let card = new Card(); |
38
|
|
|
let res = card.getRank(1); |
39
|
|
|
|
40
|
|
|
assert.equal(res, 2); |
41
|
|
|
}); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
describe("Get card with value 13", function() { |
45
|
|
|
it("should be card ♦A", function() { |
46
|
|
|
let card = new Card(); |
47
|
|
|
let res = card.getCard(13); |
48
|
|
|
|
49
|
|
|
assert.equal(res, "♦A"); |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
it("should have rank 14", function() { |
53
|
|
|
let card = new Card(); |
54
|
|
|
let res = card.getRank(13); |
55
|
|
|
|
56
|
|
|
assert.equal(res, 14); |
57
|
|
|
}); |
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
describe("Get card with value 26", function() { |
61
|
|
|
it("should be card ♠A", function() { |
62
|
|
|
let card = new Card(); |
63
|
|
|
let res = card.getCard(26); |
64
|
|
|
|
65
|
|
|
assert.equal(res, "♠A"); |
66
|
|
|
}); |
67
|
|
|
|
68
|
|
|
it("should have rank 14", function() { |
69
|
|
|
let card = new Card(); |
70
|
|
|
let res = card.getRank(26); |
71
|
|
|
|
72
|
|
|
assert.equal(res, 14); |
73
|
|
|
}); |
74
|
|
|
}); |
75
|
|
|
|
76
|
|
|
describe("Get card with value 39", function() { |
77
|
|
|
it("should be card ♥A", function() { |
78
|
|
|
let card = new Card(); |
79
|
|
|
let res = card.getCard(39); |
80
|
|
|
|
81
|
|
|
assert.equal(res, "♥A"); |
82
|
|
|
}); |
83
|
|
|
|
84
|
|
|
it("should have rank 14", function() { |
85
|
|
|
let card = new Card(); |
86
|
|
|
let res = card.getRank(39); |
87
|
|
|
|
88
|
|
|
assert.equal(res, 14); |
89
|
|
|
}); |
90
|
|
|
}); |
91
|
|
|
|
92
|
|
|
describe("Get card with value 51", function() { |
93
|
|
|
it("should be card ♥K", function() { |
94
|
|
|
let card = new Card(); |
95
|
|
|
let res = card.getCard(51); |
96
|
|
|
|
97
|
|
|
assert.equal(res, "♥K"); |
98
|
|
|
}); |
99
|
|
|
|
100
|
|
|
it("should have rank 13", function() { |
101
|
|
|
let card = new Card(); |
102
|
|
|
let res = card.getRank(51); |
103
|
|
|
|
104
|
|
|
assert.equal(res, 13); |
105
|
|
|
}); |
106
|
|
|
}); |
107
|
|
|
|
108
|
|
|
describe("Get card with value 52", function() { |
109
|
|
|
it("should be undefined", function() { |
110
|
|
|
let card = new Card(); |
111
|
|
|
let res = card.getCard(52); |
112
|
|
|
|
113
|
|
|
assert.equal(res, undefined); |
114
|
|
|
}); |
115
|
|
|
|
116
|
|
|
it("should have rank undefined", function() { |
117
|
|
|
let card = new Card(); |
118
|
|
|
let res = card.getRank(52); |
119
|
|
|
|
120
|
|
|
assert.equal(res, undefined); |
121
|
|
|
}); |
122
|
|
|
}); |
123
|
|
|
}); |
124
|
|
|
|